<?php

class Search extends BZ_Controller
{
    public function _init()
    {
        $this->load->model('scenic_category_model', 'scenic_category');
        $this->load->model('scenery_base_model', 'scenery_base');
        $this->load->model('goods_base_model', 'goods_base');
    }

    public function index()
    {
        $getData = $this->input->get();
        $getData['is_scan'] = 1;//网络预定
        /*搜索历史记录*/
        if ( !empty($getData['keyword']) ) {
            seeHistory($getData['keyword'], $type=1);
        }
        $data['result'] = $this->scenery_base->search($getData, 20, 0);
        $data['scenicCategory'] = $this->scenic_category->find()->result();
        $this->load->view('scenic/search/index', $data);
    }

    public function ajaxScenery()
    {
        $getData = $this->input->get();
        $getData['is_scan'] = 1;//网络预定
        $data['result'] = $this->scenery_base->search($getData, 20, $this->input->get('start') * 20);
        echo json_encode(array(
            'html'   => $this->load->view('scenic/search/ajaxlist', $data, true),
            'status' => $data['result']->num_rows() ? true : false,
        ));
        exit;
    }

}